package me.stone.stanimeclient.core.data.domain.fan

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import me.stone.stanimeclient.core.common.di.IoDispatcher
import me.stone.stanimeclient.core.data.domain.FlowUseCase
import me.stone.stanimeclient.core.data.domain.Result
import me.stone.stanimeclient.core.data.domain.data.ListBannerDataRepository
import me.stone.stanimeclient.core.model.FanSimpleItem
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
open class LoadBannerCase @Inject constructor(
    private val repository: ListBannerDataRepository,
    @IoDispatcher private val dispatcher: CoroutineDispatcher
) : FlowUseCase<Unit, List<FanSimpleItem>>(dispatcher) {
    override fun execute(params: Unit): Flow<Result<List<FanSimpleItem>>> {
        return flow {
            emit(Result.Loading)
            emit(Result.Success(repository.listBannerData()))
        }
    }
}

